<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let arr = [6, 3, 9, 22, 16, 4, 7, 66] //求该数组中大于平均值的数的个数，和小于平均值的个数
      function getNum(data) {
        const sb = data.reduce((sum, item) => (sum += item), 0)
        let pjz = sb / arr.length
        let a = 0
        let b = 0
        data.filter((item) => (item > pjz ? a++ : b++))
        return [a, b]
      }
      console.log(getNum(arr))
    </script>
  </body>
</html>
